package com.example.liyun.joy;

import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.view.ViewPager;
import android.view.MenuItem;

class BottomNavigationListener implements BottomNavigationView.OnNavigationItemSelectedListener {
    private MenuItem menuItem;
    private ViewPager mViewPager;

    public BottomNavigationListener(ViewPager viewPager) {
        mViewPager=viewPager;
    }


    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        menuItem=item;
        switch (item.getItemId()){
            case R.id.navigation_news:
                mViewPager.setCurrentItem(0);
                break;
            case R.id.navigation_fun:
                mViewPager.setCurrentItem(1);
                break;
        }
        return false;
    }

    public MenuItem getMenuItem() {
        return menuItem;
    }
}
